<%@ include file="/WEB-INF/jsp/includes/include.jsp" %>


<!--	BEGIN CONTENT HOLDER -->
<div id="contentHolder">


	<c:if test="${projects != null}">
		<c:forEach items="${projects}" var="project">

			<c:url scope="page" value="/project/profile.html" var="projectProfileURL">
				<c:param name="id" value="${project.id}"/>
			</c:url>
			<c:url scope="page" value="/project/joinproject.html" var="joinProjectURL">
				<c:param name="id" value="${project.id}"/>
			</c:url>
			<c:url scope="page" value="/project/leaveproject.html" var="leaveProjectURL">
				<c:param name="id" value="${project.id}"/>
			</c:url>
			<c:url scope="page" value="/messageboard/postmessage.html" var="postMessageURL">
				<c:param name="id" value="${project.id}"/>
			</c:url>
			<c:url scope="page" value="/getImage.do" var="projectImg">
				<c:param name="imgsrc" value="${project.imgSrc}"/>
			</c:url>
			<c:url scope="page" value="/project/joinproject.html" var="joinProjectURL">
				<c:param name="id" value="${project.id}"/>
			</c:url>
			<c:url scope="page" value="/project/leaveproject.html" var="leaveProjectURL">
				<c:param name="id" value="${project.id}"/>
			</c:url>
					

			<c:choose>
				<c:when test="${project.owner.organisation}">
					<c:url scope="page" value="/organisation/profile.html" var="projectOwnerProfileURL">
						<c:param name="id" value="${project.owner.id}"/>
					</c:url>
				</c:when>
				<c:when test="${project.owner.user}">
					<c:url scope="page" value="/user/profile.html" var="projectOwnerProfileURL">
						<c:param name="id" value="${project.owner.id}"/>
					</c:url>
				</c:when>
				<c:otherwise>
					<c:url scope="page" value="/group/profile.html" var="projectOwnerProfileURL">
						<c:param name="id" value="${project.owner.id}"/>
					</c:url>
				</c:otherwise>
			</c:choose>
			

			<!-- BEGIN FIRST PROJECT -->
			<div class="projectDetails">

				<div class="projectImage">
					<a href="${projectProfileURL}">
						<img src="${projectImg}" alt="${project.name}" width="70" class="profilePhoto" />
					</a>
				</div><!-- .projectImage -->

				<div class="projectExtendedInfo">

					<div class="projectNameAndOwner">
						<a href="${projectProfileURL}">${project.name}</a> by 
						<a href="${projectOwnerProfileURL}">${project.owner.name}</a>
					</div> <!-- .projectNameAndOwner -->

					<div class="projectSummary">
						${project.summary}
					</div><!-- .projectSummary -->

					<div class="projectMoreInfo">

						<table class="projectMoreInfoTable">
							<colgroup>
								<col class="col1">
								<col class="col2">
							</colgroup>
							<tr class="row1">
								<td>
									<span class="title">Project dates:</span>
									<span class="value">
										<joda:format value="${project.startDate.date}" style="S-" />
										- 
										<joda:format value="${project.endDate.date}" style="S-" />
									</span>
								</td>
								<td>
									<span class="title">Ideal for:</span>
									<span class="value">
										<c:if test="${project.recommendedForGroups}">
											<a href="#">Groups</a>	
										</c:if>													
										<c:if test="${project.recommendedForYouth}">
											<a href="#">Youth</a>	
										</c:if>
										<c:if test="${project.recommendedForKids}">
											<a href="#">Kids</a>	
										</c:if>
										<c:if test="${project.recommendedForOldies}">
											<a href="#">Oldies</a>	
										</c:if>
										<c:if test="${project.recommendedForLadies}">
											<a href="#">Ladies</a>	
										</c:if>
									</span>
								</td>
							</tr>

							<tr class="row2">
								<td>
									<span class="title">Location:</span>
									<span class="value">
										<a href="#">${project.location.suburb}</a>, 
										<a href="#">${project.location.state}</a>, 
										<a href="#">${project.location.country}</a>
									</span>
								</td>
								<td>
									<span class="title">Commitment:</span>
									<span class="value">${project.hourlyCommitment} hours a ${project.commitmentType}</span>
								</td>
							</tr>

							<tr class="row1">
								<td>
									<span class="title">Work where:</span>
									<span class="value">
										<c:if test="${project.workFromHome}">
											<a href="#">From home</a>	
										</c:if>
										<c:if test="${project.workOnSite}">
											<a href="#">On site</a>	
										</c:if>
									</span>
								</td>
								<td>
									<span class="title">Service Categories:</span>
									<span class="value">
										<c:forEach items="${project.serviceCategories}" var="serviceCategory">
											<a href="#">${serviceCategory.name}</a>
										</c:forEach>
									</span>
								</td>
							</tr>
						</table> <!-- .projectMoreInfoTable -->
					</div> <!-- .projectMoreInfo -->
				</div> <!-- .projectExtendedInfo -->

				<div class="projectDealClincher">
					<span class="viewProjectProfile">
						<a href="${projectProfileURL}">&raquo; View ${project.name}'s profile</a>
					</span>

					<span class="joinProject">

        				<handsunited:relationship entity="${loggedInUser}" member="${project}">
        					<handsunited:status status="Unknown">
		        				<a href="${joinProjectURL}">
		        					&raquo; Join project
		        				</a>
        					</handsunited:status>
        					<handsunited:status status="Active">
		        				<a href="${leaveProjectURL}">
		        					&raquo; Leave project
		        				</a>
        					</handsunited:status>
        					<handsunited:status status="AwaitingAuthorisation">
        						Awaiting Authorisation
        					</handsunited:status>
        					<handsunited:status status="ActionPending">
        						<a href="">&raquo; Authorise</a> | <a href="">&raquo; Reject</a>
        					</handsunited:status>
        				</handsunited:relationship>
					</span>
				</div><!-- .projectDealClincher -->

			</div> <!-- .projectDetails -->
			<!-- END FIRST PROJECT -->
		</c:forEach>
	</c:if>

</div> <!-- #contentHolder -->
<!-- END CONTENT HOLDER -->



<%-- 

<table width="60%" border="1" align="center" cellpadding="2" cellspacing="0">
	<c:if test="${projects != null}">
		<c:forEach items="${projects}" var="project">

			<c:url scope="page" value="/project/profile.html" var="projectProfileURL">
				<c:param name="id" value="${project.id}"/>
			</c:url>
			<c:url scope="page" value="/project/joinproject.html" var="joinProjectURL">
				<c:param name="id" value="${project.id}"/>
			</c:url>
			<c:url scope="page" value="/project/leaveproject.html" var="leaveProjectURL">
				<c:param name="id" value="${project.id}"/>
			</c:url>
			<c:url scope="page" value="/messageboard/postmessage.html" var="postMessageURL">
				<c:param name="id" value="${project.id}"/>
			</c:url>
			<c:url scope="page" value="/getImage.do" var="projectImg">
				<c:param name="imgsrc" value="${project.imgSrc}"/>
			</c:url>

			<tr>
				<td width="10%">
		        	<table width="100%" border="1">
		            	<tr>
		                	<td>
		                		<a href="${projectProfileURL}">
									<img src="${projectImg}" width="100" alt="${project.name}" border="0"/>
								</a>	                	
		                	</td>
		                </tr>
		            </table>
		        </td>
				<td width="75%">
		        	<table width="100%" border="1">
		            	<tr>
		                	<td colspan="2" align="center">
		                		<a href="${projectProfileURL}">
		                			${project.name}
		                		</a>
		                	</td>
		                			
		                </tr>
		                <tr>
		                	<td width="50%">
		                    	<table width="100%" border="1">
		                        	<tr>
		                            	<th width="100%">Network Info</th>
		                            </tr>
		                        	<tr>
		                            	<td width="100%">#Users: ${project.userNetworkSize}</td>
		                            </tr>
		                        	<tr>
		                            	<td width="100%">#Projects: ${project.projectNetworkSize}</td>
		                            </tr>
		                        	<tr>
		                            	<td width="100%">#Groups: ${project.groupNetworkSize}</td>
		                            </tr>
		                        	<tr>
		                            	<td width="100%">#Organisations: ${project.organisationNetworkSize}</td>
		                            </tr>
		                        </table>
		                    </td>
		                    <td width="50%" valign="top">
		                    	<table width="100%" border="1">
		                        	<tr>
		                            	<th width="100%">Skills Info</td>
		                            </tr>
		                            <c:forEach items="${project.skills}" var="skill">
		                            	<tr>
		                            		<td width="100%">${project.name}</td>
		                            	</tr>
		                            </c:forEach>
		                        	<tr>
		                            	<td width="100%">Woodwork</td>
		                            </tr>
		                        </table>
		                    </td>
		                </tr>
		            </table>
		        </td>
				<td width="15%">
		        	<table width="100%" border="1">
		        		<tr>
		        			<td>
		        				<handsunited:relationship entity="${loggedInUser}" member="${project}">
		        					<handsunited:status status="Unknown">
				        				<a href="${joinProjectURL}">
				        					Join project
				        				</a>
		        					</handsunited:status>
		        					<handsunited:status status="Active">
				        				<a href="${leaveProjectURL}">
				        					Leave project
				        				</a>
		        					</handsunited:status>
		        					<handsunited:status status="AwaitingAuthorisation">
		        						Awaiting Authorisation
		        					</handsunited:status>
		        					<handsunited:status status="ActionPending">
		        						Authorise | Reject
		        					</handsunited:status>
		        				</handsunited:relationship>
		        			</td>
		        		</tr>
		        		<tr>
	        				<td>
								<a href="${postMessageURL}">			        				
	        						Post a message
	        					</a>
	        				</td>
		        		</tr>
		        	</table>
		        </td>
		    </tr>
		</c:forEach>
	</c:if>	    
</table>

<c:if test="${projects != null}">

	<display:table name="projects" id="project">
		<c:url scope="page" value="/project/profile.html" var="projectProfileURL">
			<c:param name="id" value="${project.id}"/>
		</c:url>
		<c:url scope="page" value="/project/joinproject.html" var="joinProjectURL">
			<c:param name="id" value="${project.id}"/>
		</c:url>
		<c:url scope="page" value="/project/leaveproject.html" var="leaveProjectURL">
			<c:param name="id" value="${project.id}"/>
		</c:url>
		<c:url scope="page" value="/getImage.do" var="projectImg">
			<c:param name="imgsrc" value="${project.imgSrc}"/>
		</c:url>
	
		<c:set var="ownerProfileURL" value="" scope="page"/>
		
		<c:choose>
			<c:when test="${project.owner.group}">
				<c:url scope="page" value="/group/profile.html" var="ownerProfileURL">
					<c:param name="id" value="${project.owner.id}"/>
				</c:url>
			</c:when>
			<c:when test="${project.owner.user}">
				<c:url scope="page" value="/user/profile.html" var="ownerProfileURL">
					<c:param name="id" value="${project.owner.id}"/>
				</c:url>
			</c:when>
			<c:when test="${project.owner.organisation}">
				<c:url scope="page" value="/organisation/profile.html" var="ownerProfileURL">
					<c:param name="id" value="${project.owner.id}"/>
				</c:url>
			</c:when>
			<c:when test="${project.owner.organisation}">
				<c:url scope="page" value="/project/profile.html" var="ownerProfileURL">
					<c:param name="id" value="${project.owner.id}"/>
				</c:url>
			</c:when>
		</c:choose>
		
		<display:column title="Name">
			<a href="${projectProfileURL}">${project.name}</a>
		</display:column>
		<display:column title="Summary" property="summary"/>
		<display:column title="Owner">
			<a href="${ownerProfileURL}">${project.owner.name}</a>
		</display:column>
		<display:column title="Recommended For">
			<c:if test="${project.recommendedForGroups}">Groups</c:if>
			<c:if test="${project.recommendedForYouth}">Youth</c:if>
			<c:if test="${project.recommendedForKids}">Kids</c:if>
			<c:if test="${project.recommendedForOldies}">Oldies</c:if>
			<c:if test="${project.recommendedForLadies}">Ladies</c:if>
		</display:column>
		<display:column title="Work">
			<c:if test="${project.workFromHome}">From Home</c:if>
			<c:if test="${project.workOnSite}">On Site</c:if>
		</display:column>
		<display:column title="Start Date">
			<joda:format value="${project.startDate}" style="S-" />
		</display:column>
		<display:column title="End Date">
			<joda:format value="${project.endDate}" style="S-" />
		</display:column>
		<display:column title="# Volunteers Required" property="numberRequired"/>
		<display:column title="Commitment">
			${project.hourlyCommitment} hours per ${project.commitmentType}
		</display:column>
	</display:table>
</c:if>
--%>
